<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>社区矫正人员信息</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="element.css">
</head>
<body>
<div id="app" style="width: 80%; margin: 0 auto">
    <h2>社区矫正人员名单</h2>

    <el-row>
        <el-col :span="6" style="margin-bottom: 10px">
            <el-button type="primary" @click="add">新增</el-button>
            <el-input v-model="name" style="width: 70%" @keyup.enter.native="loadTable(1)"></el-input>
        </el-col>
    </el-row>

    <el-table
            :data="page.content"
            stripe
            border
            style="width: 100%">
        <el-table-column
                prop="name"
                label="用户名"
        >
        </el-table-column>
        <el-table-column
                prop="idNumber"
                label="身份证号"
                width="180">
        </el-table-column>
        <el-table-column
                prop="gender"
                label="性别">
        </el-table-column>
        <el-table-column
                prop="contactNumber"
                label="手机号">
        </el-table-column>
        <el-table-column
                prop="correctionStartDate"
                label="矫正开始日期">
        </el-table-column>
        <el-table-column
                prop="correctionEndDate"
                label="矫正结束日期">
        </el-table-column>
        <el-table-column
                prop="receptionMethod"
                label="接受方式">
        </el-table-column>
        <el-table-column
                prop="history"
                label="“四史”情况">
        </el-table-column>
        <el-table-column
                prop="isHabitualOffender"
                label="是否累惯犯">
        </el-table-column>
        <el-table-column
                prop="involvement"
                label="三涉情况">
        </el-table-column>
        <el-table-column
                prop="isCorrectionTeamCreated"
                label="是否建矫正组">
        </el-table-column>
        <el-table-column
                prop="teamComposition"
                label="人员组成情况">
        </el-table-column>
        <el-table-column
                prop="correctionReleaseType"
                label="矫正解除类型">
        </el-table-column>
        <el-table-column
                prop="isTrusteeship"
                label="是否有托管">
        </el-table-column>

        <el-table-column
                prop="trusteeshipReason"
                label="托管原因">
        </el-table-column>
        <el-table-column
                prop="supervisionStatus"
                label="检查监督情况">
        </el-table-column>
        <el-table-column
                prop="trusteeshipCorrectionStatus"
                label="托管纠正情况">
        </el-table-column>
        <el-table-column
                prop="isNeglect"
                label="是否有漏管">
        </el-table-column>
        <el-table-column
                prop="neglectReason"
                label="漏管原因">
        </el-table-column>
        <el-table-column
                prop="neglectSupervisionStatus"
                label="检查监督情况">
        </el-table-column>
        <el-table-column
                prop="neglectCorrectionStatus"
                label="漏管纠正情况">
        </el-table-column>
        <el-table-column
                prop="rewardAndPunishmentStatus"
                label="奖惩情况">
        </el-table-column>
        <el-table-column
                prop="penaltyExecutionStatus"
                label="刑罚执行情况">
        </el-table-column>
        <el-table-column
                prop="isReoffended"
                label="是否从新犯罪">
        </el-table-column>
        <el-table-column
                prop="reoffenseName"
                label="重新犯罪名称">
        </el-table-column>
        <el-table-column
                fixed="right"
                label="操作"
                width="100">
            <template slot-scope="scope">
                <el-button type="primary" icon="el-icon-edit" size="small" circle @click="edit(scope.row)"></el-button>
                <el-button type="danger" icon="el-icon-delete" size="small" circle @click="del(scope.row.id)"></el-button>
            </template>
        </el-table-column>
    </el-table>
    <el-row type="flex" justify="center" style="margin-top: 10px">
        <el-pagination
                layout="prev, pager, next"
                :page-size="pageSize"
                :current-page="pageNum"
                @prev-click="loadTable"
                @current-change="loadTable"
                @next-click="loadTable"
                :total="page.totalElements">
        </el-pagination>
    </el-row>

    <el-dialog
            title="用户信息"
            :visible.sync="dialogVisible"
            width="30%">
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="姓名">
                <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="身份证号">
                <el-input v-model="form.idnumber"></el-input>
            </el-form-item>
            <el-form-item label="性别" prop="gender">
                <el-select v-model="form.gender" placeholder="请选择性别">
                    <el-option label="男" value="男"></el-option>
                    <el-option label="女" value="女"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="联系电话">
                <el-input v-model="form.contactNumber"></el-input>
            </el-form-item>

            <el-form-item label="开始矫正日期">
                <el-input v-model="form.correctionStartDate"></el-input>
            </el-form-item>
            <el-form-item label="结束矫正日期">
                <el-input v-model="form.correctionEndDate"></el-input>
            </el-form-item>
            <el-form-item label="接收方式">
                <el-select v-model="form.receptionMethod" placeholder="请选择活动区域">
                    <el-option label="自行报道" value="自行报道"></el-option>
                    <el-option label="狱所押送" value="狱所押送"></el-option>
                    <el-option label="当庭交接" value="当庭交接"></el-option>
                    <el-option label="其他" value="其他"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="“四史”情况">
                <el-select v-model="form.history" placeholder="请选择活动区域">
                    <el-option label="吸毒史" value="吸毒史"></el-option>
                    <el-option label="逃脱史" value="逃脱史"></el-option>
                    <el-option label="自杀史" value="自杀史"></el-option>
                    <el-option label="袭警史" value="袭警史"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="是否累惯犯">
                <el-input v-model="form.isHabitualOffender"></el-input>
            </el-form-item>
            <el-form-item label="三涉情况">
                <el-select v-model="form.involvement" placeholder="请选择活动区域">
                    <el-option label="涉毒" value="涉毒"></el-option>
                    <el-option label="涉黑" value="涉黑"></el-option>
                    <el-option label="涉枪" value="涉枪"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="是否建矫正组">
                <el-input v-model="form.isCorrectionTeamCreated"></el-input>
            </el-form-item>
            <el-form-item label="人员组成情况">
                <el-select v-model="form.teamComposition" placeholder="请选择活动区域">
                    <el-option label="司法所工作人员" value="司法所工作人员"></el-option>
                    <el-option label="社会工作人员" value="社会工作人员"></el-option>
                    <el-option label="志愿者" value="志愿者"></el-option>
                    <el-option label="村（居）委会人员" value="村（居）委会人员"></el-option>
                    <el-option label="所在单位人员" value="所在单位人员"></el-option>
                    <el-option label="就读学校人员" value="就读学校人员"></el-option>
                    <el-option label="家庭成员或监护人" value="家庭成员或监护人"></el-option>
                    <el-option label="保证人" value="保证人"></el-option>
                    <el-option label="其他" value="其他"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="矫正解除类型">
                <el-select v-model="form.correctionReleaseType" placeholder="请选择活动区域">
                    <el-option label="期满解除" value="期满解除"></el-option>
                    <el-option label="收监执行" value="收监执行"></el-option>
                    <el-option label="死亡" value="死亡"></el-option>
                    <el-option label="居住地更变" value="居住地更变"></el-option>
                    <el-option label="其他" value="其他"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="是否有托管">
                <el-input v-model="form.isTrusteeship"></el-input>
            </el-form-item>
            <el-form-item label="托管原因">
                <el-input v-model="form.trusteeshipReason"></el-input>
            </el-form-item>
            <el-form-item label="检查监督情况">
                <el-input v-model="form.supervisionStatus"></el-input>
            </el-form-item>
            <el-form-item label="托管纠正情况">
                <el-input v-model="form.trusteeshipCorrectionStatus"></el-input>
            </el-form-item>
            <el-form-item label="是否有漏管">
                <el-input v-model="form.isNeglect"></el-input>
            </el-form-item>
            <el-form-item label="漏管原因">
                <el-input v-model="form.neglectReason"></el-input>
            </el-form-item>
            <el-form-item label="检查监督情况">
                <el-input v-model="form.neglectSupervisionStatus"></el-input>
            </el-form-item>
            <el-form-item label="漏管纠正情况">
                <el-input v-model="form.neglectCorrectionStatus"></el-input>
            </el-form-item>
            <el-form-item label="奖惩情况">
                <el-input v-model="form.rewardAndPunishmentStatus"></el-input>
            </el-form-item>
            <el-form-item label="刑罚执行情况">
                <el-input v-model="form.penaltyExecutionStatus"></el-input>
            </el-form-item>
            <el-form-item label="是否从新犯罪">
                <el-input v-model="form.isReoffended"></el-input>
            </el-form-item>
            <el-form-item label="重新犯罪名称">
                <el-input v-model="form.reoffenseName"></el-input>
            </el-form-item>





        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="save">确 定</el-button>
        </span>
    </el-dialog>

</div>

<script src="jquery.min.js"></script>
<script src="vue.js"></script>
<!-- 引入组件库 -->
<script src="element.js"></script>

<script>
    new Vue({
        el: '#app',
        data: {
            page: {},
            name: '',
            pageNum: 1,
            pageSize: 8,
            dialogVisible: false,
            form: {}
        },
        created() {
            this.loadTable(this.pageNum);
        },
        methods: {
            loadTable(num) {
                this.pageNum = num;
                $.get("/sqjz/page?pageNum=" + this.pageNum + "&pageSize=" + this.pageSize + "&name=" + this.name).then(res => {
                    this.page = res.data;
                });
            },
            add() {
                this.dialogVisible = true;
                this.form = {};
            },
            edit(row) {
                this.form = row;
                this.dialogVisible = true;
            },
            save() {
                let data = JSON.stringify(this.form);
                if (this.form.id) {
                    // 编辑
                    $.ajax({
                        url: '/sqjz',
                        type: 'put',
                        contentType: 'application/json',
                        data: data
                    }).then(res => {
                        this.dialogVisible = false;
                        this.loadTable(1);
                    })
                } else {
                    // 新增
                    $.ajax({
                        url: '/sqjz',
                        type: 'post',
                        contentType: 'application/json',
                        data: data
                    }).then(res => {
                        this.dialogVisible = false;
                        this.loadTable(1);
                    })
                }
            },
            del(id) {
                $.ajax({
                    url: '/sqjz/' + id,
                    type: 'delete',
                    contentType: 'application/json'
                }).then(res => {
                    this.loadTable(1);
                })
            }
        }
    })
</script>
</body>
</html>
